#include <memory>
#include "TcpServer.hpp"
#include "Calculator.hpp"
#include "Protocol.hpp"
#include "Parser.hpp"
#include "Daemon.hpp"
int main(int argc,char* argv[])
{
    Daemon();//变为守护进程
    EnableConsoleLogStrategy();//启动日志

    //1.计算模块
    std::unique_ptr<Cal> cal = std::make_unique<Cal>();

    //2.解析模块
    std::unique_ptr<Parser> parser = std::make_unique<Parser>([&cal](Request& req)->Response
    {
        return cal->Exe(req);
    });

    //3.网络通信模块
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>([&parser](const std::string& inbuffer)->std::string
    {
        return parser->Parse(inbuffer);
    },(uint16_t)std::stoi(argv[1]));
    tsvr->Start();    
    return 0;
}